Pensieve Header: A 2D B-Picture.

SetDirectory["C:\\drorbn\\AcademicPensieve\\Projects\\w-Computations"]

HeadsMerge[x_,y_,z_][mix_] := Module[
{cox, coy,jx,jy,jxy},
cox = D[mix, h[x]] /. t[s_] :> c[s];
coy = D[mix, h[y]] /. t[s_] :> c[s];
jx=If[cox===0, 1, (((-1+(E^cox)))/cox)];
jy=If[coy===0, 1, (((-1+(E^coy)))/coy)];
jxy=If[cox+coy===0, 1, (((-1+(E^(cox+coy))))/(cox+coy))];
(mix /. {h[x]->0, h[y]->0})+ ((jx h[z]D[mix, h[x]])/jxy) + (E^cox)((jy h[z]D[mix, h[y]])/jxy) 
]

HeadsMerge[3,4,5][t[1]h[3]+t[2]h[4]]

a=t[1]h[4]+t[2]h[5]+t[3]h[6]

HeadsMerge[4,5,7][a]

Expand2[expr_] := Series[expr /. {c[i_]:> z c[i], t[i_] :> z t[i]}, {z,0,2}]

HeadsMerge[4,5,7][a] // Expand2

HeadsMerge[7,6,8][HeadsMerge[4,5,7][a]] // Simplify

HeadsMerge[4,7,8][HeadsMerge[5,6,7][a]] // Simplify

(HeadsMerge[7,6,8][HeadsMerge[4,5,7][a]] - HeadsMerge[4,7,8][HeadsMerge[5,6,7][a]]) // Simplify

a=Sum[Random[]t[i]h[j], {i,4},{j,4}]

Simplify[HeadsMerge[1,2,6][a]]

t1=Simplify[HeadsMerge[6,3,7][Simplify[HeadsMerge[1,2,6][a]]]]

t2=Simplify[HeadsMerge[1,6,7][Simplify[HeadsMerge[2,3,6][a]]]]

Simplify[t1-t2 /. {c[1] -> Random[], c[2] -> Random[], c[3] -> Random[], c[4] -> Random[]}]